package com.ctshk.sapp.order.season.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.order.season.dto.SeasonOrderTouristDataDTO;
import com.ctshk.rpc.order.season.req.SeasonOrderTouristDataReq;
import com.ctshk.rpc.order.season.service.ISeasonOrderTouristService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 套票订单旅客信息 前端控制器
 * </p>
 *
 * @author 杨林
 * @since 2021-03-24
 */
@Api(value = "预订中心套票-订单中心旅客", tags = "预订中心套票-订单中心旅客")
@RestController
@RequestMapping("/season-order-tourist")
public class SeasonOrderTouristController extends BaseController {

    @DubboReference
    private ISeasonOrderTouristService seasonOrderTouristService;

    @ApiOperation(value = "订单中心-套票-旅客信息列表", notes = "订单中心-套票-旅客信息列表")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心-套票-旅客信息列表", operDesc = "订单中心-套票-旅客信息列表")
    @PostMapping("/touristList/{id}")
    public Result<List<SeasonOrderTouristDataDTO>> findTouristList(@PathVariable Long id) {
        TokenUser user = getCurrentUser(getRequest());
        List<SeasonOrderTouristDataDTO> touristList = seasonOrderTouristService.getTouristListById(id);
        return Result.success(touristList);

    }


    @ApiOperation(value = "订单中心-套票-获取旅客信息", notes = "订单中心-套票-获取旅客信息")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心-套票-获取旅客信息", operDesc = "订单中心-套票-获取旅客信息")
    @PostMapping("/findTouristInfo/{id}")
    public Result findTouristInfo(@PathVariable Long id) {
        TokenUser user = getCurrentUser(getRequest());
        return seasonOrderTouristService.findTouristInfo(user, id);
    }

    @ApiOperation(value = "订单中心-套票-修改旅客信息", notes = "订单中心-套票-修改旅客信息")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心-套票-修改旅客信息", operDesc = "订单中心-套票-修改旅客信息")
    @PostMapping("/editTourist")
    public Result editTourist(@RequestBody SeasonOrderTouristDataReq req) {
        TokenUser user = getCurrentUser(getRequest());
        return seasonOrderTouristService.editTourist(user, req);
    }

}
